package socket;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;

public class SendDemo {
    public static void main(String[] args) throws IOException {
        //1.创建socket对象
        Socket socket = new Socket("127.0.0.1",1002);
        //2.创建流对象
        OutputStream os = socket.getOutputStream();
        //3.向流中添加数据\
        os.write("你好".getBytes());
        //4.释放资源
        os.close();
        socket.close();
    }
}
